/**
 * @file CCdiant.h
 * @brief Fichier d'entête du module CC.
 *
 * @author Mohammad NOROUZZADEH, Lotfi, Saleh
 */
#ifndef _FENETRES_H
#define _FENETRES_H


/* ********************************************************************* */
/*                                                                       */
/*                       Librairies de FENETRES                       */
/*                                                                       */
/* ********************************************************************* */

#include <stdlib.h>
#include <gtk/gtk.h>
#include <stdio.h>
#include <string.h>

#include  "Application.h"


/*omid*/
/************Fenetre Admin****************/
static GtkWidget * FenAdmin;
static GtkWidget * tablePrincipal_Admin;

static GtkHBox * hbox1_Admin;
static GtkHBox * hbox2_Admin;
static GtkHBox * hbox3_Admin;
static GtkHBox * hbox4_Admin;
static GtkHBox * hbox5_Admin;


static GtkHSeparator * hsep1_Admin;
static GtkHSeparator * hsep2_Admin;
static GtkHSeparator * hsep3_Admin;
static GtkHSeparator * hsep4_Admin;



static GtkLabel	* label_titre_Admin;

static GtkButton * bouton_AjoutEtu_Admin;
static GtkButton * bouton_AjoutEns_Admin;
static GtkButton * bouton_AjoutUE_Admin;
static GtkButton * bouton_AjoutSalle_Admin;

void initFenAdmin();
void cb_quit_fenAdmin();
/****************************************/
/***Fenetre AjoutEns***/
static GtkWidget * FenAjoutEns;

static GtkWidget * tablePrincipal_AjoutEns;

static GtkLabel	* label_titre_AjoutEns;
static GtkLabel	* label_numEns_AjoutEns;
static GtkLabel	* label_nomEns_AjoutEns;
static GtkLabel	* label_prenomEns_AjoutEns;

static GtkEntry	* entry_numEns_AjoutEns;
static GtkEntry	* entry_nomEns_AjoutEns;
static GtkEntry	* entry_prenomEns_AjoutEns;

static GtkHBox * hbox1_AjoutEns;
static GtkHBox * hbox2_AjoutEns;
static GtkHBox * hbox3_AjoutEns;
static GtkHBox * hbox4_AjoutEns;

static GtkHSeparator * hsep1_AjoutEns;
static GtkHSeparator * hsep2_AjoutEns;
static GtkHSeparator * hsep3_AjoutEns;
static GtkHSeparator * hsep4_AjoutEns;

static GtkButton * bouton_valider_AjoutEns;

void initFenAjoutEns();
void    cb_quit_fenAjoutEns();
/********/
/***Fenetre AjoutEtu***/
static GtkWidget * FenAjoutEtu;

static GtkWidget * tablePrincipal_AjoutEtu;

static GtkLabel	* label_titre_AjoutEtu;
static GtkLabel	* label_numEtu_AjoutEtu;
static GtkLabel	* label_nomEtu_AjoutEtu;
static GtkLabel	* label_prenomEtu_AjoutEtu;

static GtkEntry	* entry_numEtu_AjoutEtu;
static GtkEntry	* entry_nomEtu_AjoutEtu;
static GtkEntry	* entry_prenomEtu_AjoutEtu;

static GtkHBox * hbox1_AjoutEtu;
static GtkHBox * hbox2_AjoutEtu;
static GtkHBox * hbox3_AjoutEtu;
static GtkHBox * hbox4_AjoutEtu;

static GtkHSeparator * hsep1_AjoutEtu;
static GtkHSeparator * hsep2_AjoutEtu;
static GtkHSeparator * hsep3_AjoutEtu;
static GtkHSeparator * hsep4_AjoutEtu;

static GtkButton * bouton_valider_AjoutEtu;

void initFenAjoutEtu();
void cb_quit_fenAjoutEtu();

/********/
/***Fenetre AjoutSalle***/
static GtkWidget * FenAjoutSalle;

static GtkWidget * tablePrincipal_AjoutSalle;

static GtkLabel	* label_titre_AjoutSalle;
static GtkLabel	* label_numSalle_AjoutSalle;
static GtkLabel	* label_IntituleSalle_AjoutSalle;


static GtkEntry	* entry_numSalle_AjoutSalle;
static GtkEntry	* entry_IntituleSalle_AjoutSalle;

static GtkHBox * hbox1_AjoutSalle;
static GtkHBox * hbox2_AjoutSalle;
static GtkHBox * hbox3_AjoutSalle;


static GtkHSeparator * hsep1_AjoutSalle;
static GtkHSeparator * hsep2_AjoutSalle;
static GtkHSeparator * hsep3_AjoutSalle;


static GtkButton * bouton_valider_AjoutSalle;

void initFenAjoutSalle();
void cb_quit_fenAjoutSalle();

/********/
/***Fenetre AjoutUE***/
static GtkWidget * FenAjoutUE;

static GtkWidget * tablePrincipal_AjoutUE;

static GtkLabel	* label_titre_AjoutUE;
static GtkLabel	* label_codeUE_AjoutUE;
static GtkLabel	* label_IntituleUE_AjoutUE;
static GtkLabel	* label_SeqenceUE_AjoutUE;

static GtkEntry	* entry_codeUE_AjoutUE;
static GtkEntry	* entry_IntituleUE_AjoutUE;
static GtkEntry	* entry_SeqenceUE_AjoutUE;

static GtkHBox * hbox1_AjoutUE;
static GtkHBox * hbox2_AjoutUE;
static GtkHBox * hbox3_AjoutUE;
static GtkHBox * hbox4_AjoutUE;

static GtkHSeparator * hsep1_AjoutUE;
static GtkHSeparator * hsep2_AjoutUE;
static GtkHSeparator * hsep3_AjoutUE;
static GtkHSeparator * hsep4_AjoutUE;

static GtkButton * bouton_valider_AjoutUE;

void initFenAjoutUE();
void cb_quit_fenAjoutUE();

/********/
void    connectSignal_FenAdmin();
void    connectSignal_FenAjoutEtu();
void    connectSignal_FenAjoutEns();
void    connectSignal_FenAjoutUE();
void    connectSignal_FenAjoutSalle();

void    cb_valider_ajoutEtu();
void    cb_valider_ajoutEns();
void    cb_valider_ajoutESalle();
void    cb_valider_ajoutUE();

void cb_ouvrir_FenAjoutEtu();
void cb_ouvrir_FenAjoutEns();
void cb_ouvrir_FenAjoutUE();
void cb_ouvrir_FenAjoutESalle();

/*******/
/*endomid*/

static  GtkWidget * windowFenIp;

static  GtkWidget* scrollWinTableEtu;
static  GtkWidget* scrollTableUe;
static  GtkWidget* tablePrincipal;

static  GtkWidget* table_etu;
static  GtkWidget* table_ue_etu;
static  GtkWidget* table_ue;
static  GtkWidget* table_bouton_fen_ip;

static  GtkHSeparator * sep1;
static  GtkHSeparator * sep2;
static  GtkHSeparator * sep3;

static  GtkLabel* label1;
static  GtkLabel* label2;
static  GtkLabel* label3;

static  GtkButton* inscrireBouton;
static  GtkButton* desinscrireBouton;

static  int numEtuSel;

/**
 * @fn initFenIp();
 * @brief initFenIp

 * @return 0 si tout est OK
 */
void initFenIp();

/********************************/
/************Fenetre GestionUE****************/
static GtkWidget * FenGestionUE;
static GtkWidget * tablePrincipal_GestionUE;

static GtkHBox * hbox1_GestionUE;
static GtkHBox * hbox2_GestionUE;
static GtkHBox * hbox3_GestionUE;
static GtkHBox * hbox4_GestionUE;
static GtkHBox * hbox5_GestionUE;
static GtkHBox * hbox6_GestionUE;
static GtkHBox * hbox7_GestionUE;
static GtkHBox * hbox8_GestionUE;
static GtkHBox * hbox9_GestionUE;
static GtkHBox * hbox10_GestionUE;
static GtkHBox * hbox11_GestionUE;

static GtkHBox * hbox_enseignantCM_GestionUE;
static GtkHBox * hbox_chargeTD_GestionUE;
static GtkHBox * hbox_chargeTP_GestionUE;
static GtkHBox * hbox_CM_GestionUE;
static GtkHBox * hbox_TD_GestionUE;
static GtkHBox * hbox_TP_GestionUE;
static GtkHBox * hbox_evaluation_GestionUE;
static GtkHBox * hbox_moyenne_GestionUE;

static GtkHSeparator * hsep1_GestionUE;
static GtkHSeparator * hsep2_GestionUE;
static GtkHSeparator * hsep3_GestionUE;
static GtkHSeparator * hsep4_GestionUE;
static GtkHSeparator * hsep5_GestionUE;
static GtkHSeparator * hsep6_GestionUE;
static GtkHSeparator * hsep7_GestionUE;

static GtkLabel	* label_titre_GestionUE;
static GtkLabel	* label_nbEtu_GestionUE;
static GtkLabel	* label_nbGroupe_GestionUE;
static GtkLabel	* label_codeUE_GestionUE;

static GtkLabel	* label_respUE_GestionUE;
static GtkLabel	* label_enseignantCM_GestionUE;
static GtkLabel	* label_chargeTD_GestionUE;
static GtkLabel	* label_chargeTP_GestionUE;

static GtkLabel	* label_enseigementUE_GestionUE;
static GtkLabel	* label_CM_GestionUE;
static GtkLabel	* label_TD_GestionUE;
static GtkLabel	* label_TP_GestionUE;

static GtkLabel	* label_evaluation_GestionUE;
static GtkLabel	* label_listEvaluation_GestionUE;

static GtkLabel	* label_noteUE_GestionUE;
static GtkLabel	* label_moyenneUE_GestionUE;

static GtkButton * bouton_defgroupe_GestionUE;
static GtkButton * bouton_modif_enseignantCM_GestionUE;
static GtkButton * bouton_modif_chargeTD_GestionUE;
static GtkButton * bouton_modif_chargeTP_GestionUE;
static GtkButton * bouton_modif_CM_GestionUE;
static GtkButton * bouton_modif_TD_GestionUE;
static GtkButton * bouton_modif_TP_GestionUE;
static GtkButton * bouton_modif_evaluation_GestionUE;
static GtkButton * bouton_noteEtu_GestionUE;
static GtkButton * bouton_valoriser_GestionUE;
static GtkButton * bouton_fermer_GestionUE;

static GtkLinkButton * bouton_link_GestionUE;


void initFenGestionUE();
void cb_quit_fenGestionUE();
/****************************************/




/***Fenetre Identification***/
static GtkWidget * FenIdentification;

static GtkWidget * tablePrincipal_Identifiant;

static GtkLabel	* label_titre_Identifiant;
static GtkLabel	* label_Identifiant;
static GtkLabel	* label_mdp_Identifiant;

static GtkEntry	* entry_Identifiant;
static GtkEntry	* entry_mdp_Identifiant;

static GtkHBox * hbox1_Identifiant;
static GtkHBox * hbox2_Identifiant;
static GtkHBox * hbox3_Identifiant;
static GtkHBox * hbox4_Identifiant;


static GtkHSeparator * hsep1_Identifiant;
static GtkHSeparator * hsep2_Identifiant;
static GtkHSeparator * hsep3_Identifiant;
static GtkHSeparator * hsep4_Identifiant;
static GtkHSeparator * hsep5_Identifiant;

static GtkButton * bouton_valider_Identifiant;

/**
 * @fn initFenIdentification();
 * @brief initFenIdentification

 * @return 0 si tout est OK
 */
void initFenIdentification();

/**
 * @fn reAfficheFenetreIdentification();
 * @brief reAfficheFenetreIdentification

 * @return 0 si tout est OK
 */
void reAfficheFenetreIdentification();
/********/

/***Fenetre Etudiant***/
static GtkWidget * FenEtudiant;

static GtkWidget * tablePrincipal_Etudiant;
static GtkWidget * table_ip_Etudiant;
static GtkWidget * table_tomuss_Etudiant;

static GtkLabel	* label_numEtu_Etudaint;
static GtkLabel	* label_nomEtu_Etudaint;
static GtkLabel	* label_prenomEtu_Etudaint;
static GtkLabel	* label_ip_Etudaint;
static GtkLabel	* label_cours_Etudaint;
static GtkLabel	* label_tomuss_Etudaint;

static GtkWidget	* image_Etudiant;

static GtkHBox * hbox1_Etudiant;
static GtkHBox * hbox2_Etudiant;

static GtkHSeparator * hsep1_Etudiant;
static GtkHSeparator * hsep2_Etudiant;
static GtkHSeparator * hsep3_Etudiant;
static GtkHSeparator * hsep4_Etudiant;

static GtkVSeparator * vsep1_Etudiant;
static GtkVSeparator * vsep2_Etudiant;
static GtkVSeparator * vsep3_Etudiant;

static GtkTextView * textview_Etudiant;
static GtkButton * bouton_deconnection_Etudiant;

/**
 * @fn initFenEtudiant();
 * @brief initFenEtudiant

 * @return 0 si tout est OK
 */
void initFenEtudiant();

/**
 * @fn preparerFenetreEtudiant();
 * @brief preparerFenetreEtudiant

 * @return 0 si tout est OK
 */
void preparerFenetreEtudiant(Etu * etu);
/**********************************************/

/***Fenetre Presence***/
static GtkWidget * windowFenPresence;

static GtkWidget * tablePrincipal_presence;
static GtkWidget * table_etu_Presence;

static GtkLabel	* label_enseignement_presence;

static GtkWidget * scrollWinTableEtuPrecence;

static GtkHSeparator * sep1_Presence;
static GtkHSeparator * sep2_Presence;

static GtkButton * bouton_valider_presence;

/**
 * @fn preparerFenetreDefGroupe();
 * @brief preparerFenetreDefGroupe
 * @param[in] enseignement

 * @return 0 si tout est OK
 */
void initFenPresence(Enseignement*enseignement);
void    connectSignal_FenetrePresence();

/**
 * @fn preparerFenetreDefGroupe();
 * @brief preparerFenetreDefGroupe
 * @param[in] enseignement

 * @return 0 si tout est OK
 */
void preparerFenetrePresence(Enseignement*ens);
/*****************************************************/


/***Fenetre DefGroupe***/
static GtkWidget * FenDefGroupe;

static GtkWidget * tablePrincipal_DefGroupe;

static GtkLabel	* label_NumUE_DefGroupe;
static GtkLabel	* label_nb_DefGroupe;

static GtkHBox * hbox1_DefGroupe;
static GtkHBox * hbox2_DefGroupe;

static GtkComboBox * combboxDefGroupe;

static GtkHSeparator * sep1_DefGroupe;
static GtkHSeparator * sep2_DefGroupe;
static GtkHSeparator * sep3_DefGroupe;

static GtkButton * bouton_valider_DefGroupe;

/**
 * @fn initFenDefGroupe();
 * @brief initFenDefGroupe

 * @return 0 si tout est OK
 */
void initFenDefGroupe();

/**
 * @fn preparerFenetreDefGroupe();
 * @brief preparerFenetreDefGroupe

 * @return 0 si tout est OK
 */
void preparerFenetreDefGroupe();
/**********************************************/


/* ********************************************************************* */
/*                                                                       */
/*                        Définitions de types                           */
/*                                                                       */
/* ********************************************************************* */

/**
 * @struct sFenetre
 * @brief Structure utilisée pour la gestion d'une Etu.
 *
 * Cette structure est utilisée pour gérer .Les champs de cette structures
   doivent être modifiés ou lus par les accesseurs et mutateurs.
 */
struct sFenetre
{
    GtkWindow  *    fenetreEnseignant;
    GtkWindow  *   fenetreGererUe;
    GtkWindow* fenetreListUeEns;
};

/**
 * @typedef Fenetre
 * @brief Redéfinit la structure sFenetre
 */
typedef struct sFenetre Fenetre;


static  GtkBuilder  *  p_builder;
static  GError      *  p_err;
static  const   char* srcXML=SRC_XML;
static  Fenetre  *   listFenetres;

/**
 * @fn connectSignal_FenetreEnseignant();
 * @brief connectSignal_FenetreEnseignant

 * @return 0 si tout est OK
 */
void    connectSignal_FenetreEnseignant();

/**
 * @fn connectSignal_FenetreEtudiant();
 * @brief connectSignal_FenetreEtudiant

 * @return 0 si tout est OK
 */
void    connectSignal_FenetreEtudiant();

/**
 * @fn connectSignal_FenetreGererUe();
 * @brief connectSignal_FenetreGererUe

 * @return 0 si tout est OK
 */
void    connectSignal_FenetreGererUe();

/**
 * @fn connectSignal_FenetreIdentification();
 * @brief connectSignal_FenetreIdentification

 * @return 0 si tout est OK
 */
void    connectSignal_FenetreIdentification();

/**
 * @fn connectSignal_FenetreListUeEns();
 * @brief connectSignal_FenetreListUeEns

 * @return 0 si tout est OK
 */
void    connectSignal_FenetreListUeEns();





/**
 * @fn afficheFenetre(GtkWindow*window);
 * @brief afficheFenetre

 * @param[in, out] window
 * @return 0 si tout est OK
 */
void    afficheFenetre(GtkWindow*window);

/**
 * @fn void deployerUI(int argc,char**argv);
 * @brief deployerUI

 * @param[in, out] int argc
 * @param[in, out] char**argv

 * @return 0 si tout est OK
 */
void    deployerUI(int argc,char**argv);

/**
 * @fn void lancerUI();
 * @brief lancerUI

 * @return 0 si tout est OK
 */
void    lancerUI();

/**
 * @fn void chargerInterface();
 * @brief chargerInterface


 * @return 0 si tout est OK
 */
void    chargerInterface();

/**
 * @fn void chargerInterface();
 * @brief chargerInterface

 * @param[in, out] log
 * @return 0 si tout est OK
 */
void    lancerApplication(Login *log);

/**
 * @fn void lancerApplicationEtudiant(Etu*etudiant);
 * @brief lancerApplicationEtudiant

 * @param[in, out] etu
 * @return 0 si tout est OK
 */
void    lancerApplicationEtudiant(Etu*etudiant);

/**
 * @fn void lancerApplicationEnseignant(Ens*enseignant);
 * @brief lancerApplicationEnseignant

 * @param[in, out] ens
 * @return 0 si tout est OK
 */
void    lancerApplicationEnseignant(Ens*enseignant);

/**
 * @fn void lancerApplicationAdministrateur();
 * @brief lancerApplicationAdministrateur

 * @return 0 si tout est OK
 */
void    lancerApplicationAdministrateur();

/**
 * @fn void lancerApplicationScolarite();
 * @brief lancerApplicationScolarite

 * @return 0 si tout est OK
 */
void    lancerApplicationScolarite();

/**
 * @fn void initEtuTableTomuuss(Etu*etu,GtkTable*tableTomuss,TabUe*tabUe);
 * @brief initEtuTableTomuuss

 * @param[in, out] Etu
 * @param[in, out] tableTomuss
 * @param[in, out] tabUe
 * @return 0 si tout est OK
 */
void    initEtuTableTomuuss(Etu*etu,GtkTable*tableTomuss,TabUe*tabUe);

/**
 * @fn void initEnsTableTomuuss(Ens*ens,GtkTable*tableTomuss,TabUe*tabUe);
 * @brief initEnsTableTomuuss

 * @param[in, out] Ens
 * @param[in, out] tableTomuss
 * @param[in, out] tabUe
 * @return 0 si tout est OK
 */
void    initEnsTableTomuuss(Ens*ens,GtkTable*tableTomuss,TabUe*tabUe);

/**
 * @fn GtkWidget*    recHBoxPourUeEns(Ens*ens,UE*ue);
 * @brief

 * @param[in, out] ens
 * @param[in, out] ue
 * @return GtkWidget
 */
GtkWidget*    recHBoxPourUeEns(Ens*ens,UE*ue);

/**
 * @fn GtkWidget*    recHBoxPourUeEtu(Etu*etu,UE*ue);
 * @brief

 * @param[in, out] etu
 * @param[in, out] ue
 * @return GtkWidget
 */
GtkWidget*    recHBoxPourUeEtu(Etu*etu,UE*ue);



/**
 * @fn void setImageProfil(int id,char*    idImage);
 * @brief setImageProfil

 * @param[in, out] ip
 * @param[in, out] idimage
 * @return 0 si tout est OK
 */
void setImageProfil(int id,char*    idImage);

/**
 * @fn void cb_enseignement_click(GtkWidget *widg, GdkEvent *event, gpointer message);
 * @brief cb_enseignement_click

 * @param[in, out] widg
 * @param[in, out] event
 * @param[in, out] message
 * @return 0 si tout est OK
 */
void    cb_enseignement_click(GtkWidget *widg, GdkEvent *event, gpointer message);

/**
 * @fn void cb_enseignant_gerer_ue_bouton_click();
 * @brief cb_enseignant_gerer_ue_bouton_click

 * @return 0 si tout est OK
 */
void    cb_enseignant_gerer_ue_bouton_click();

/**
 * @fn void cb_gerer_ue(GtkWidget *widg, GdkEvent *event, gpointer message);
 * @brief cb_gerer_ue

 * @param[in, out] widg
 * @param[in, out] event
 * @param[in, out] message

 * @return 0 si tout est OK
 */
void    cb_gerer_ue(GtkWidget *widg, GdkEvent *event, gpointer message);

/**
 * @fn void cb_enseignant_gerer_ip_bouton_click();
 * @brief cb_enseignant_gerer_ip_bouton_click

 * @return 0 si tout est OK
 */
void    cb_enseignant_gerer_ip_bouton_click();

/**
 * @fn void set_dialog_def_groupe();
 * @brief set_dialog_def_groupe

 * @return 0 si tout est OK
 */
void    set_dialog_def_groupe();

/**
 * @fn void hide_window(GtkWidget *  widg);
 * @brief hide_window

 * @param[in, out] widg
 * @return 0 si tout est OK
 */
void    hide_window(GtkWidget *  widg);

/**
 * @fn void cb_inscrire_etu();
 * @brief cb_inscrire_etu

 * @return 0 si tout est OK
 */
void cb_inscrire_etu();

/**
 * @fn void cb_inscrire_etu_par_ue(GtkWidget*widg);
 * @brief cb_inscrire_etu_par_ue

 * @param[in, out] widg
 * @return 0 si tout est OK
 */
void    cb_inscrire_etu_par_ue(GtkWidget*widg);

/**
 * @fn void cb_desinscrire_etu_par_ue(GtkWidget*widg);
 * @brief cb_desinscrire_etu_par_ue

 * @param[in, out] widg
 * @return 0 si tout est OK
 */
void    cb_desinscrire_etu_par_ue(GtkWidget*widg);

/**
 * @fn void cb_desinscrire_etu();
 * @brief cb_desinscrire_etu

 * @return 0 si tout est OK
 */
void    cb_desinscrire_etu();

/**
 * @fn void cb_def_auto_gr();
 * @brief cb_def_auto_gr

 * @param[in, out]
 * @return 0 si tout est OK
 */
void cb_def_auto_gr();



/***********callback pour quitter l'application************/

/**
 * @fn void cb_quit_application_etudiant();
 * @brief cb_quit_application_etudiant

 * @return 0 si tout est OK
 */
void cb_quit_application_etudiant();

/**
 * @fn void cb_quit_application_enseignant();
 * @brief cb_quit_application_enseignant

 * @return 0 si tout est OK
 */
void cb_quit_application_enseignant();

/**
 * @fn void cb_quit_application_admin();
 * @brief cb_quit_application_admin

 * @return 0 si tout est OK
 */
void cb_quit_application_admin();

/**
 * @fn void v();
 * @brief cb_quit_application

 * @return 0 si tout est OK
 */
void cb_quit_application();

/**
 * @fn void cb_quit_identification();
 * @brief cb_quit_identification

 * @return 0 si tout est OK
 */
void cb_quit_identification();

/**
 * @fn void cb_quit_fenDefGroupe();
 * @brief cb_quit_fenDefGroupe

 * @return 0 si tout est OK
 */
void cb_quit_fenDefGroupe();

/**
 * @fn void cb_quit_fenPresence();
 * @brief cb_quit_fenPresence

 * @return 0 si tout est OK
 */
void cb_quit_fenPresence();

/**
 * @fn void cb_quit_fenIp();
 * @brief cb_quit_fenIp

 * @return 0 si tout est OK
 */
void cb_quit_fenIp();
/**************************************************************/
void cb_valid_presence(GtkWidget *widg, GdkEvent *event, gpointer message);
void  cb_for_etu_pre_valid(GtkWidget *widg, GdkEvent *event, gpointer message);


#endif
